#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <Trajectory3DManager.h>
#include <osg/Switch>
#include <Point3D.h>
#include <osgFX/Outline>
#include <SceneViewerFunctions.h>
#include <CallBackTest.h>
Trajectory3DManager::Trajectory3DManager() : osg::MatrixTransform()
{

}

Trajectory3DManager::Trajectory3DManager(const Trajectory3DManager & Trajectory3DManager, const osg::CopyOp &copyop) : MatrixTransform(Trajectory3DManager,copyop)
{
}

Trajectory3DManager::~Trajectory3DManager()
{

}

bool Trajectory3DManager::addChild(osg::Node *child)
{
    bool result = false;
    //Trajectory3D* trajectoryPtr = dynamic_cast<Trajectory3D*>(child);
    //if(trajectoryPtr != NULL)
    {
        //osg::ref_ptr<Trajectory3D> trajectorySmartPtr = trajectoryPtr;


    }

    //osgFX::Outline* outLinePtr = dynamic_cast<osgFX::Outline*>(child);
    //if(outLinePtr == NULL)
    {
        result = osg::MatrixTransform::addChild(child);
    }


    return result;
}

void Trajectory3DManager::setupTimeOffset()
{
    double timeSum = 0;
    for(int i = 0; i < this->getNumChildren(); i++)
    {
        Trajectory3D* trajectoryPtr = dynamic_cast<Trajectory3D*>(this->getChild(i));
        if(trajectoryPtr != NULL)
        {
            trajectoryPtr->setLoopMode(osg::AnimationPath::LoopMode::NO_LOOPING);
            trajectoryPtr->setTimeOffset(timeSum);
            timeSum += trajectoryPtr->getDurationTime();

        }
    }
}

//bool Trajectory3DManager::removeChildren(unsigned int pos, unsigned int numChildrenToRemove)
//{

//}

